package io;

import java.io.*;

/*
BufferedInputStream:缓冲输入流
BufferedOutputStream:缓冲输出流
 */
public class CopyDemo3Buffered {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("image.jpg");
        BufferedInputStream bis=new BufferedInputStream(fis);
        FileOutputStream fos=new FileOutputStream("image_cp1.jpg");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        int d;
        while ((d=bis.read())!=0){
            bos.write(d);
        }
        System.out.println("复制完毕");
        bis.close();
        bos.close();





        /*FileInputStream fis=new FileInputStream("image.jpg");
        BufferedInputStream bis=new BufferedInputStream(fis);
        FileOutputStream fos=new FileOutputStream("image_cp1.jpg");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        long start=System.currentTimeMillis();
        int d;
        while ((d= bis.read())!=-1){
            bos.write(d);
        }
        long end=System.currentTimeMillis();
        System.out.println("复制完毕，耗时"+(end-start)+"ms");
        bis.close();
        bos.close();

         */
    }
}
